package com.lyy.worker;

import com.lyy.utils.RabbitMqUtils;
import com.rabbitmq.client.Channel;

import java.util.Scanner;

/**
 *生产者发送大量消息
 */

public class provider01 {
    private static final String QUEUE_NAME ="hello";

    public static void main(String[] args) throws Exception{
        Channel channel = RabbitMqUtils.getChannel();
        //队列声明
        channel.queueDeclare(QUEUE_NAME,false,false,false,null);
        //发送消息,从控制台发送
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String message = scanner.next();
            channel.basicPublish("",QUEUE_NAME,null,message.getBytes());
            System.out.println("发送消息完成"+message);

        }


    }
}
